//每100毫秒监听是否输入密码正确进入到注册页面
		setInterval(function() {
			var width = $(window).width();
			var height = $(window).height();
			console.log(height)
			$(".register_1").attr("style", "height:" + height / 2 + "px ;");
			$(".register_2").attr("style", "height:" + height / 2 + "px ;");
			if($(".register_input1").val() == $(".register_m1").html() && $(".register_input2").val() == $(".register_m2").html() && $(".register_input3").val() == $(".register_m3").html() && $(".register_input4").val() == $(".register_m4").html() && $(".register_m1").html() !== "") {
				$("#register_center").fadeIn(1000)
				$(".register_1").attr("style", "display: none;");
				$(".register_2").attr("style", "display: none;");
				$(".register_m1").attr("style", "display: none;");
				$(".register_m2").attr("style", "display: none;");
				$(".register_m3").attr("style", "display: none;");
				$(".register_m4").attr("style", "display: none;");
			}
			$("#register_input").attr("style","left: "+(width/2-width*0.16)+"px;top:" + height / 2 + "px ;width:"+(width-width*0.68)+"px ; height:"+(width-width*0.94)+"px;")
			$(".register_input1").attr("style","margin-left:"+(width-width*0.997)+"px;width:"+(width-width*0.955)+"px;height:"+(width-width*0.955)+"px;");
			$(".register_input2").attr("style","margin-left:"+(width-width*0.9568)+"px;width:"+(width-width*0.955)+"px;height:"+(width-width*0.955)+"px;");
			$(".register_input3").attr("style","margin-left:"+(width-width*0.956)+"px;width:"+(width-width*0.955)+"px;height:"+(width-width*0.955)+"px;");
			$(".register_input4").attr("style","margin-left:"+(width-width*0.9567)+"px;width:"+(width-width*0.955)+"px;height:"+(width-width*0.955)+"px;");
		}, 100)
		//接入leanCloud注册邮箱
		var isreg = false;
			window.onload = function() {
				var APP_ID = 'c4w6bVvWfh8xxcmkBE1G0gIt-gzGzoHsz';
				var APP_KEY = 'JBikg4Ksk76zcTi5BKYWvTJF';
				AV.init({
					appId: APP_ID,
					appKey: APP_KEY
				});
			}

			function yzEmail(t) {
				var ret = /^([A-z0-9_\.\-])+\@(([A-z0-9\-])+\.)+([A-z0-9]{2,4})+$/;//验证邮箱
				if (!ret.test($("#register_email").val())) {
					$("#register_TorF").attr("style","background-image: url(img/login/TorF.png);background-position-x: -40px;")
					$("#register_center .register_tishiyu").attr("style","display: block;");
				}else{
					$("#register_TorF").attr("style","background-image: url(img/login/TorF.png);")
				}
				AV.User.requestEmailVerify(t.value).then(function(result) {
					isreg = false;
					alert("该邮箱已经被注册")
				}, function(error) {
					isreg = true;
				});
			}

			function reg() {
				if(isreg) {
					var register_email = $("#register_email").val();
					var register_pwd = $("#register_pwd").val();
					// 新建 AVUser 对象实例
					var user = new AV.User();
					// 设置用户名
					user.setUsername(register_email);
					// 设置密码
					user.setPassword(register_pwd);
					// 设置邮箱 
					user.setEmail(register_email);
					user.signUp().then(function(loginedUser) {
						alert("注册成功");
						location.href='login.html';
					}, function(error) {
						console.log(error)
					});
				} else {
					alert("请更换邮箱")
				}
			}

//狗头晃动开始
old_x = 0;
old_y = 0;
dir = [];
keys = new Array();
keys['up'] = 5;
keys['down'] = 1;
keys['right'] = 7;
keys['left'] = 3;
keys['enter,space'] = 0;
keys['a'] = 10;
keys['s'] = 3;
keys['d'] = 4;
keys['f'] = 5;
keys['g'] = 6;
keys['h'] = 7;
keys['j'] = 8;
keys['k'] = 9;
keys['l'] = 2;
keys[';'] = 2;
$(document).ready(function() {
	resetDirs = function() {
		dir = ['c', 's', 'sv', 'v', 'nv', 'n', 'ne', 'e', 'se', 's', 'c1', 'cc'];
	}
	resetDirs();
	changeOne = function(element, direction) {
		element.attr('class', 'eye eye_' + dir[direction]);
	}
	setupMouse = function() {
		$(document).mousemove(function(e) {
			m_x = e.pageX;
			m_y = e.pageY;
			r_x = m_x - old_x;
			r_y = m_y - old_y;
			rdo = parseInt(Math.random() * 10);
			//			console.log(m_x +"x轴"+m_y +"y轴")
			
				if(m_x <= 623 && m_y <= 111) {
				$(".register_m1").on("mouseover", function() {
					$(".register_m1").attr("style", "font-size: 30px;");
					$(".register_m1").html(rdo);
				})
				$(".register_m1").fadeIn(1000);
			}
			if(m_x <= 670 && m_y >= 135) {
				$(".register_m2").on("mouseover", function() {
					$(".register_m2").attr("style", "font-size: 30px;");
					$(".register_m2").html(rdo)
				})
				$(".register_m2").fadeIn(1000)
			}
			if(m_x >= 690 && m_y >= 135) {
				$(".register_m3").on("mouseover", function() {
					$(".register_m3").attr("style", "font-size: 30px;");
					$(".register_m3").html(rdo)
				})
				$(".register_m3").fadeIn(1000)
			}
			if(m_x >= 760 && m_y <= 130) {
				$(".register_m4").on("mouseover", function() {
					$(".register_m4").attr("style", "font-size: 30px;");
					$(".register_m4").html(rdo)
				})
				$(".register_m4").fadeIn(1000)
			}
			

			dist = Math.sqrt(r_x * r_x + r_y * r_y);
			if(dist > 15) {
				old_x = m_x;
				old_y = m_y;
				$('.eye').each(function() {
					redraw($(this), m_x, m_y);
				});
			}
		});
	};
	redraw = function(element, mx, my) {
		pos = element.offset();
		half_width = element.width() / 2;
		half_height = element.height() / 2;
		i_x = pos.left + (half_width);
		i_y = pos.top + (half_height)
		rel_x = mx - i_x;
		rel_y = my - i_y;
		dist = Math.sqrt(rel_x * rel_x + rel_y * rel_y);

		if(dist > half_width || dist > half_height) {
			angle = Math.acos(-rel_y / dist) * 57.3248;
			sign = (rel_x > 0) ? 1 : -1;
			angle = angle * sign;
			p = Math.round(angle / 45) + 5;
			changeOne(element, p);
		} else {
			changeOne(element, 11);
		}
	}
	setupMouse();
})
//狗头晃动结束